﻿#ifndef EPOLLHEAD
#define EPOLLHEAD
#include"SocketHead.hpp"
#include <algorithm>
#include <thread>
#include<sys/epoll.h>

int sock_init(int port);

int DoFind();

int DoRead();

int DoAdd();

void handle_event(int epollfd, epoll_event *events, int num, int listenfd, char *buf);

void handle_accept(int epollfd,int listenfd);

void do_read(int epollfd,int fd,char*buf);

void do_write(int epollfd,int fd,char*buf);

void add_event(int epollfd,int fd,int state);

void modi_event(int epollfd,int fd,int state);

void del_event(int epollfd,int fd,int state);

void do_epoll(int listenfd);

int epoll_main();

///<summary>增加上下线信息</summary>
void AddOnlineStateMsg(int sock_fd,bool isOnline);
///<summary>广播</summary>
void Broadcast(std::string msg);
///<summary>广播线程</summary>
void* t_Broadcast(void *args);

#endif
